<link rel="stylesheet" href="<?php echo base_url() . 'assets/js/themes/base/jquery.ui.all.css'; ?>"/>
<script src="<?php echo base_url() . 'assets/js/jquery-1.9.1.js'; ?>"></script>
<script src="<?php echo base_url() . 'assets/js/ui/jquery.ui.core.js'; ?>"></script>
<script src="<?php echo base_url() . 'assets/js/ui/jquery.ui.widget.js'; ?>"></script>
<script src="<?php echo base_url() . 'assets/js/ui/jquery.ui.datepicker.js'; ?>"></script>
<script>
	$(function() {
		$("#created_date").datepicker();
	});

	function showPreview(ele)
	{
			$('#imgAvatar').attr('src', ele.value); // for IE
            if (ele.files && ele.files[0]) {
			
                var reader = new FileReader();
				
                reader.onload = function (e) {
                    $('#image_preview').attr('src', e.target.result);
                }

                reader.readAsDataURL(ele.files[0]);
            }
	}
</script>
<?php echo validation_errors(); ?>
<?php echo anchor(base_url(), "Home"); ?>
<?php echo form_open_multipart("article/Article/update"); ?>
<input type="hidden" name="id" id="id" value="<?php echo set_value('id', $params -> id); ?>"/>
<input type="hidden" name="image_id" id="image_id" value="<?php echo set_value('id', $params -> image_id); ?>"/>
<input type="hidden" name="action" id="action" value="save"/>

<table>
  <tr>
    <td><label for="title">Title</label></td>
    <td><input type="text" name="title" id="title" value="<?php echo set_value('title', $params -> title); ?>"/></td>
  </tr>
  <tr>
    <td><label for="image_path">Image</label></td>
    <td><img id="image_preview" src="<?php echo $image -> url;?>"><input type="file" name="image_path" id="image_path" value="<?php echo set_value('image_path', $image -> url); ?>" OnChange="showPreview(this)"/></td>
  </tr>
  <tr>
    <td><label for="created_date">Created date</label></td>
    <td><input type="text" name="created_date" id="created_date" value="<?php echo set_value('created_date', $params -> created_date); ?>"/></td>
  </tr>
  <tr>
    <td><label for="summary">Summary</label></td>
    <td><input type="text" name="summary" id="summary" value="<?php echo set_value('summary', $params -> summary); ?>"/></td>
  </tr>
  <tr>
    <td><label for="catalog_id">Catalog</label></td>
    <td>
    	<select name="catalog_id">
    	<?php foreach ($catalog_list as $catalog) {?>
    		<option value="<?php echo $catalog -> id; ?>" <?php echo set_select('catalog_id', $catalog->id)?> selected="<?php
			if ($params -> catalog_id == $catalog -> id)
				echo 'selected';
		?>"><?php echo $catalog -> catalog_name; ?></option>
    	<?php } ?>
    	</select>
    </td>
  </tr>
 <tr>
  	<td><input type="submit" value="Update"/></td>
  	<td></td>
  </tr>
</table>
<?php echo form_close(); ?>
